#include <QTimer>

#include "qenternumpaycard.h"


QEnterNumPayCard::QEnterNumPayCard(QWidget *parent)
    : QWidget(parent)
{
	ui.setupUi(this);
	ui.lineEdit->clear();

	balanceState = new QFrame(parent);
	QBitmap bitmap(".//img/balanceState.png" );
	QRegion region( bitmap);
	QRect boundRect = region.boundingRect();

	balanceState->setMask( region.boundingRect());
	balanceState->setObjectName( QString::fromUtf8( "balanceState" ) );
	// balanceState->setStyleSheet( QString::fromUtf8( "#balanceState{ background-image: url(:/mainWnd/img/balanceState.png)}") );
	balanceState->setWindowFlags(Qt::SplashScreen);

	QPoint point( x(), y() );
	balanceState->move( mapToGlobal(point));

}

QEnterNumPayCard::~QEnterNumPayCard()
{

}
void QEnterNumPayCard::paintEvent(QPaintEvent * event ){

	QPainter painter( this );

	QBitmap bitmap(".//img/enterNumPayCard.png" );
	QRegion region( bitmap);
	QRect boundRect = region.boundingRect();

	setMask( region.boundingRect());
}

void QEnterNumPayCard::OnEditingFinished(){

	setNumPayCard();

	QTimer *timer = new QTimer(this);
	connect(timer, SIGNAL(timeout()), this, SLOT( update() ));
	timer->start(3000); //wait for 3 secs to close the form

	balanceState->show();

	close();
}
void QEnterNumPayCard::update(){

	balanceState->close();
}
void QEnterNumPayCard::setNumPayCard(){

	numPayCard_ = ui.lineEdit->text();
}
